package com.syht.wechatpay.controller;


import com.tencent.common.Configure;
import com.tencent.common.GetOpenId;
import com.tencent.common.WeiXinOauth2Token;
import com.tencent.protocol.pay_protocol.ScanPayReqData;
import com.tencent.service.IServiceRequest;
import com.tencent.service.ScanPayService;

public class Test {

	public static void  paysss(){
		
		//https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx6e282be064c6b239&redirect_uri=http://www.19ea.com/com/aaa&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect 
		String appid = "wx6e282be064c6b239";
		String appSecret = "85c96eea9e5cc54cf2aa9a5bffeeca4c";
		String code = "021IxGQr15h2Ur0vloUr1p7EQr1IxGQX";
		
		WeiXinOauth2Token wx = GetOpenId.getOauth2AccessToken(appid, appSecret, code);
		System.out.println(wx.getOpenId());
		
		String spBillCreateIP = "192.168.1.7";
		String body = "下单测试";
		String attach = "附加数据";
		String outTradeNo = "20160804000001";
		String totalMoney = "1";
		String timeStart = "20160804112010";
		String timeExpire = "20160804112510";
		String goodsTag = "WXG";
		String deviceInfo = "001";
		Integer totalFee = totalMoney.isEmpty() ? 0 : Integer.valueOf(totalMoney);
		
		try {
			ScanPayService scanPayService = new ScanPayService();
			ScanPayReqData scanPayReqData = new ScanPayReqData(body, attach, outTradeNo, totalFee, deviceInfo, spBillCreateIP, timeStart, timeExpire, goodsTag);
			scanPayService.request(scanPayReqData);
		} catch (Exception e) {

			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) {


		 try {
			
			 Class<?> c = Class.forName(Configure.HttpsRequestClassName);
		     System.out.println(c.getName());
		} catch (Exception e) {
			
			e.printStackTrace();
		}
	}
}
